package cn.edu.cqu.fredyvia.forum.entity.enums;

import cn.edu.cqu.fredyvia.forum.entity.Talk;
import com.baomidou.mybatisplus.annotation.IEnum;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
public enum TalkTypeEnum   implements IEnum<Integer> {
    JOURNALISM(1,"新闻"),
    MILITARY(2,"军事"),
    SPORTS(3,"体育"),
    ENTERTAINMENT(4,"娱乐"),
    FINANCE_ECONOMICS(5,"财经"),
    SCIENCE_TECHNOLOGY(6,"科技"),
    FASHION(7,"时尚"),
    EDUCATION(8,"教育"),
    GAME(9,"游戏"),
    OTHER(10,"其他");
    String name;
    int index;

    private static final Map<Integer, TalkTypeEnum> CODE_MAP = new HashMap<Integer, TalkTypeEnum>();

    static {
        for (TalkTypeEnum typeEnum : TalkTypeEnum.values()) {
            CODE_MAP.put(typeEnum.getIndex(), typeEnum);
        }
    }
    TalkTypeEnum(int index,String name) {
        this.name = name;
        this.index = index;
    }

    public static TalkTypeEnum getEnum(Integer code) {
        return CODE_MAP.get(code);
    }
//    public static void main(String[] args) {
//        TalkTypeEnum.GAME.getName();
//    }

    @Override
    public Integer getValue() {
        return index;
    }
}

